<template>
	<view class="groupactiveauditlist">
		<view class="groupactiveauditlist_top_block">
			<view class="groupactiveauditlist_tabs">
				<view @click="changeTabs(-1)"
					:class="params.status==-1?'groupactiveauditlist_tabs_cell tabs_on':'groupactiveauditlist_tabs_cell'">
					全部</view>
				<view @click="changeTabs(0)"
					:class="params.status==0?'groupactiveauditlist_tabs_cell tabs_on':'groupactiveauditlist_tabs_cell'">
					待审核</view>
				<view @click="changeTabs(1)"
					:class="params.status==1?'groupactiveauditlist_tabs_cell tabs_on':'groupactiveauditlist_tabs_cell'">
					审核通过</view>
				<view @click="changeTabs(2)"
					:class="params.status==2?'groupactiveauditlist_tabs_cell tabs_on':'groupactiveauditlist_tabs_cell'">
					未通过</view>
			</view>
			<view class="groupactiveauditlist_table_header">
				<uni-row gutter="8">
					<uni-col :span="4">
						<view class="text-c">ID</view>
					</uni-col>
					<uni-col :span="9">
						<view class="text-c">姓名</view>
					</uni-col>
					<uni-col :span="6">
						<view class="text-c">报名日期</view>
					</uni-col>
					<uni-col :span="5">
						<view class="text-c">审核状态</view>
					</uni-col>
				</uni-row>
			</view>
		</view>
		<view class="f-14">
			<view v-for="(item,index) in list" :key="item.id" class="groupaudit_cell" @click="goInfo(item.id)">
				<uni-row gutter="8">
					<uni-col :span="4">
						<view class="col_table_cell display_flex">{{item.id}}</view>
					</uni-col>
					<uni-col :span="9">
						<view v-if="item.club_name" class="col_table_cell">
							<view class="ellipsis">{{item.name}}</view>
							<view class="ellipsis f-10">{{item.club_name}}</view>
						</view>
						<view v-else class="col_table_cell display_flex">{{item.name}}</view>
					</uni-col>
					<uni-col :span="6">
						<view class="col_table_cell display_flex">
							{{item.create_time?item.create_time.substring(0,10):'无'}}
						</view>
					</uni-col>
					<uni-col :span="5">
						<view class="col_table_cell display_flex green" v-if="item.status == 1">通过</view>
						<view class="col_table_cell display_flex red" v-else-if="item.status == 0">待审核</view>
						<view class="col_table_cell display_flex black" v-else>未通过</view>
					</uni-col>
				</uni-row>
			</view>
			<view class="page_bottom_loading" :style="'padding-bottom:'+pdbottom+'rpx;'">{{loadingTitle}}</view>

		</view>
	</view>
</template>

<script>
	import {
		getGroupActiveAuditList,
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				club_id: '',
				huodong_id: '',
				params: {
					club_id: '',
					huodong_id: '',
					status: -1,
					sign_status: '',
					page: 1,
					size: 15,
				},
				list: [],
				loadingTitle: '',
				pdbottom: uni.getSystemInfoSync().safeAreaInsets.bottom ? uni.getSystemInfoSync().safeAreaInsets.bottom +
					60 : 60,
			};
		},
		onShow() {
			if (!uni.getStorageSync('access_token')) {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}
			if (uni.getStorageSync('userinfo').is_staff == 0) {
				uni.switchTab({
					url: '/pages/index/index'
				})
			}else{
				if (uni.getStorageSync('onload')) {
					this.params.page = 1
					this.list = []
					this.getGroupActiveAuditList()
					uni.removeStorage({
						key: 'onload'
					})
				}
			}
		},
		onLoad(options) {
			if (uni.getStorageSync('userinfo').is_staff != 0) {
				this.club_id = options.club_id ? options.club_id : ''
				this.params.club_id = options.club_id ? options.club_id : ''
				this.huodong_id = options.huodong_id ? options.huodong_id : ''
				this.params.huodong_id = options.huodong_id ? options.huodong_id : ''
				this.getGroupActiveAuditList()
			}
			var params = {
				event_code: '车友会活动报名审核管理',
				path: 'pages/groupmanage/groupactiveauditlist',
				event_id: '',
				title: '',
				source_page: '',
				value: '',
			}
			app.BurialPoint(params)
		},
		methods: {
			getGroupActiveAuditList() {
				getGroupActiveAuditList(this.params).then(res => {
					if (res.state == 1) {
						this.list = [...this.list, ...res.data.data]
						this.current_page = res.data.current_page
						this.last_page = res.data.last_page
						if (this.list.length == 0) {
							this.loadingTitle = "- 暂无更多 -"
						}
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},

			changeTabs(index) {
				this.params.status = index
				this.params.page = 1
				this.list = []
				this.getGroupActiveAuditList()
			},
			goInfo(id) {
				uni.navigateTo({
					url: '/pages/groupmanage/groupactiveauditinfo?id=' + id + '&club_id=' + this.club_id
				})
			}
		},
		onPullDownRefresh() {
			this.params.page = 1
			this.list = []
			this.getGroupActiveAuditList()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if (this.current_page < this.last_page) {
				this.showLoading = true
				this.params.page = this.params.page + 1
				this.getGroupActiveAuditList()
			} else {
				this.showLoading = false
				if (this.list.length > 0) {
					this.loadingTitle = "- 已经到底了 -"
				} else {
					this.loadingTitle = "- 暂无更多 -"
				}

			}
		}
	}
</script>

<style lang="scss">
	.groupactiveauditlist {
		padding: 0 30rpx 50rpx 30rpx;

		.groupactiveauditlist_top_block {
			padding-top: 30rpx;
			position: sticky;
			top: 0;
			z-index: 1;
			background-color: #ffffff;

			.groupactiveauditlist_tabs {
				height: 80rpx;
				font-size: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-around;
				border-radius: 8rpx;
				border: 2rpx solid #E9E9E9;

				.groupactiveauditlist_tabs_cell {
					width: 25%;
					height: 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-right: 4rpx solid #000000;
				}

				.groupactiveauditlist_tabs_cell:last-child {
					border-right: 0;
				}

				.tabs_on {
					color: #00A0DC;
				}

				// .tabs_on:first-child {
				// 	border-top-left-radius: 8rpx;
				// 	border-bottom-left-radius: 8rpx;
				// }

				// .tabs_on:last-child {
				// 	border-top-right-radius: 8rpx;
				// 	border-bottom-right-radius: 8rpx;
				// }
			}

			.groupactiveauditlist_table_header {
				font-size: 24rpx;
				margin: 40rpx 0 30rpx 0;
				padding: 30rpx 0;
				border-radius: 8rpx;
				background-color: #F2F2F2;
			}
		}

		.groupaudit_cell {
			padding: 30rpx 0;
			margin-bottom: 30rpx;
			border-radius: 8rpx;
			background-color: #F7F7F7;

			.col_table_cell {
				height: 70rpx;
				text-align: center;
				justify-content: center;
			}

			.green {
				color: #07C061;
			}

			.red {
				color: #EE2A2A;
			}

			.black {
				color: #666666;
			}
		}
	}
</style>